# Contributor: Jose-Luis Rivas <ghostbar@riseup.net>
# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libuv
pkgver=1.37.0
pkgrel=0
pkgdesc="Cross-platform asychronous I/O"
url="https://libuv.org"
arch="all"
license="MIT AND ISC"
makedepends_build="automake autoconf libtool"
makedepends_host="linux-headers"
subpackages="$pkgname-static $pkgname-dev $pkgname-dbg"
source="https://dist.libuv.org/dist/v$pkgver/libuv-v$pkgver.tar.gz
	disable-test-failing-on-builders.patch
	"
builddir="$srcdir/$pkgname-v$pkgver"

prepare() {
	default_prepare
	sh autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make CFLAGS="$CFLAGS -D__USE_MISC" BUILDTYPE=Release
}

check() {
	# see https://github.com/libuv/libuv/issues/2307
	case $CARCH in
		x86*)
			if test $DRONE; then
				sed -i "s/TEST_.*(ipc_closed_handle)//g" test/test-list.h
			fi
		;;
	esac

	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm644 LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="dc5f616871d8ea10d7d5f66f5b1044eb1deeab7714a5fb515a40ca9a45d01efea310c182b74a4152da26c9de9ca75b0ba13b103eb0e63361144216aac408223a  libuv-v1.37.0.tar.gz
0d155259cfaa78fd229a015fd7181b9a76bf4618e36e6e9d4697323cddcde42f29598f161f6831489ec31adc5cf2614cb670021bf6f5ede7202bcbad7f675fbb  disable-test-failing-on-builders.patch"
